<script type="text/javascript">
$(document).ready(function(){
	$('a[class="tblank"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});
	$("#guardarContrato").click(function(){
		parent.$.fancybox.close();
	});
});
</script>
<?php 
require_once('../Connections/tecno.php'); 
$id = $_REQUEST['id'];

$f=date('Y-m-d'); 

$insertSQL = "INSERT INTO contratos (idContrato, fechaContrato, status) VALUES ('', '$f','0')";								
mysql_select_db($database_tecno, $tecno);
$Result1 = mysql_query($insertSQL, $tecno) or die(mysql_error());
$id_c= mysql_insert_id();

	   $art = $_REQUEST['idArt'];
   $n        = count($art);
	   $i        = 0;
	   $sql_det = "idArt IN ("; 

		while ($i < $n){
			  if($n-$i==1){
				 $sql_det .= "'".$art[$i]."')"; 
			  }else{
				  $sql_det .= "'".$art[$i]."',";
		 		   }
				$i++; 
	     }
	$sql_det;


		$updateSQL = "UPDATE detallescliente SET idContrato= '$id_c' WHERE ". $sql_det;								
			mysql_select_db($database_tecno, $tecno);
			$Result1 = mysql_query($updateSQL, $tecno) or die(mysql_error());

?>
<a href="reportes/contrato.php?id=<?php echo $id_c; ?>" class="tblank"> 
	<div name="guardarContrato" id="guardarContrato" class="botonGrande" style="float:left;">Imprimir Contrato</div>
</a>
